package com.hxci.hospital.config;

import com.hxci.hospital.interceptor.AuthInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthInterceptor())
                .addPathPatterns("/hospital/**") // 拦截所有hospital开头的请求
                .excludePathPatterns(
                        "/hospital/",  // 排除首页
                        "/hospital/index",  // 排除首页
                        "/hospital/patient/**",  // 排除患者相关请求
                        "/hospital/doctor/login",
                        "/hospital/doctor/tologin",
                        "/hospital/ai/**",  // 排除AI相关请求
                        "/js/**",
                        "/css/**"
                ); // 排除登录相关请求和静态资源
    }
}
